package com.foo.ui_demo_widge;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import java.lang.reflect.TypeVariable;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tvdemo = findViewById(R.id.tv_demo);
        tvdemo.setText("测试");
        tvdemo.setWidth(256);
        tvdemo.setHeight(256);
        tvdemo.setBackgroundColor(Color.RED);//背景颜色
        tvdemo.setTextColor(Color.BLUE);//字体颜色
        tvdemo.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);//字体大小
        tvdemo.setTypeface(Typeface.DEFAULT_BOLD);//加粗
        tvdemo.setScaleX(2.0f);
        tvdemo.setScaleY(2.0f);
        tvdemo.setBackgroundResource(R.drawable.ic_launcher_background);
        tvdemo.setGravity(Gravity.CENTER);
        tvdemo.setPadding(10,20,10,0);

    }
}